import { PixiController } from "./infrastructure/PixiController";
import { JsonParser } from "./json-parse/JsonParser";

export class Application {

  private pixiController: PixiController = new PixiController();

  private jsonParser: JsonParser = new JsonParser();

  constructor() {
    console.log("Application started.");
  }

  init() {

    this.pixiController.initPixiApp();
    this.jsonParser.init();

  }

  public test() {
    this.pixiController.test();
  }

  async drawLineFromJson() {
    // 读取该路径的json
    const jsonDataUrl = "./2dConversionData.json";

    try {
      const response = await fetch(jsonDataUrl);
      if (!response.ok) {
        throw new Error(`HTTP error! Status: ${response.status}`);
      }

      const data = await response.json();
      this.jsonParser.startParserJson(data);
      console.log("JSON data:", data);
    }
    catch (error) {
      console.error("Error fetching JSON:", error);
    }

  }
}
